home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
tex
/
td187src.lzh
/
FILE.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
17KB
|
649 lines
IMPLEMENTATION MODULE File ;
FROM SYSTEM IMPORT ADDRESS , ADR;
FROM Storage IMPORT ALLOCATE , DEALLOCATE ;
FROM Dialoge IMPORT BusyStart, BusyEnd;
FROM Diverses IMPORT GetFSelText, NumAlert;
FROM Types IMPORT DrawObjectTyp, TextPosTyp, CodeAryTyp,
CharPtrTyp, ObjectPtrTyp;
IMPORT MagicDOS ;
IMPORT MagicStrings;
IMPORT MagicSys;
IMPORT mtAlerts ;
IMPORT Diverses;
IMPORT GetFile;
IMPORT FileIO;
IMPORT Variablen ;
IMPORT CommonData ;
(**
IMPORT RTD;
**)
TYPE ReadOrWrite = ( R , W ) ;
VAR FileHandle : INTEGER ;
Button : INTEGER ;
FileVersion: INTEGER ;
Idum : INTEGER ;
Bdum : BOOLEAN ;
Cdum : CARDINAL ;
Ldum : MagicSys.lCARDINAL ;
MergeMode : BOOLEAN;
PROCEDURE Correct(REF Filename : ARRAY OF CHAR;
VAR unilen,
resolution,
release : INTEGER ) : BOOLEAN;
VAR res : BOOLEAN;
long : MagicSys.lCARDINAL;
Handle : INTEGER;
Button : INTEGER;
code : ARRAY [0..39] OF INTEGER;
adr : ADDRESS;
num : ARRAY [0..9] OF CHAR;
dtaptr : MagicDOS.PtrDTA;
BEGIN
(**
RTD.SetDevice(RTD.printer);
RTD.Write('Correct:', Filename);
**)
res := TRUE;
long := 20 ;
adr := ADR ( code );
dtaptr := MagicDOS.Fgetdta() ;
Button := MagicDOS.Fsfirst ( Filename ,
{MagicDOS.ReadOnly, MagicDOS.Archive,
MagicDOS.Hidden, MagicDOS.System});
IF (Button=0) AND (dtaptr^.dLength>=20) THEN
FileIO.Reset(Handle, Filename);
IF Handle<0 THEN
res := FALSE;
ELSE
(**
MagicDOS.Fread ( Handle , long , adr ) ;
**)
FileIO.ReadNWords(Handle, 10, code);
FileIO.Close ( Handle ) ;
IF ORD(code[0])<>ORD(Picture) THEN
res := FALSE;
END;
unilen := code[6];
resolution := code[7];
release := code[8];
IF (resolution<1) OR (resolution>5) THEN
resolution := 3;
END; (* altes Format *)
END;
ELSE
res := FALSE;
END;
IF NOT res THEN
mtAlerts.SetIcon(mtAlerts.Graphic);
(**
Button := Diverses.Alert(1, NoPicFile);
**)
Button := NumAlert(4, 1);
END;
(**
RTD.Message('Leaving Correct');
**)
RETURN res;
END Correct;
PROCEDURE SelectFile ( VAR Name : ARRAY OF CHAR;
MSG : ARRAY OF CHAR;
LeaveName : BOOLEAN;
HasToExist : BOOLEAN ) : INTEGER ;
VAR titel : ARRAY [ 0..128 ] OF CHAR ;
path : ARRAY [ 0..128 ] OF CHAR ;
file : ARRAY [ 0..12 ] OF CHAR ;
ext : ARRAY [ 0..4 ] OF CHAR ;
tmp1,tmp2: ARRAY [ 0..14 ] OF CHAR ;
titeladr : ADDRESS ;
fileadr : ADDRESS ;
drive : CARDINAL ;
index : INTEGER ;
merke : INTEGER ;
dummy : BOOLEAN;
BEGIN
(**
RTD.Message('Into SelectFile ');
**)
IF LeaveName THEN
MagicStrings.Assign(Name, titel);
GetFile.ReplacePath(titel, '');
END;
tmp1 := '*.';
tmp2 := '.';
MagicStrings.Append(CommonData.Extensions[1], tmp1);
MagicStrings.Append(CommonData.Extensions[1], tmp2);
IF GetFile.GetFileName(Name, titel, tmp1, tmp2, CommonData.LTDPath, MSG,
dummy, LeaveName, HasToExist, TRUE, FALSE) THEN
(**
RTD.Message('Leaving SelectFile ');
**)
RETURN 1;
ELSE
(**
RTD.Message('Leaving SelectFile ');
**)
RETURN 0;
END;
END SelectFile ;
PROCEDURE ReadWriteFile ( FileName : ARRAY OF CHAR;
RW : ReadOrWrite;
SelectFlag : BOOLEAN ) : BOOLEAN ;
(* Lese bzw. schreibe Baum *)
VAR rw : CARDINAL ;
long : MagicSys.lCARDINAL ;
long2 : MagicSys.lCARDINAL ;
adr : ADDRESS ;
z : INTEGER;
dummy : BOOLEAN;
lookset : BITSET;
num : ARRAY [ 0..3 ] OF CHAR ;
object : ObjectPtrTyp ;
code : CodeAryTyp ;
cptr : CharPtrTyp ;
eptr : ADDRESS;
cbuffer : ARRAY [0..255] OF CHAR;
Surround : ARRAY [0..3] OF INTEGER;
PROCEDURE SaveTree(first : ObjectPtrTyp;
Subpic, OnlySelected : BOOLEAN) ;
VAR object : ObjectPtrTyp ;
number : INTEGER;
BEGIN
(**
RTD.Message('Into SaveTree');
**)
IF Subpic THEN
object := first^.Children;
ELSE
object := first^.Next;
END;
number := 0;
WHILE object<>NIL DO
IF OnlySelected THEN
IF object^.Selected THEN
number := number + 1;
END;
ELSE
number := number + 1;
END;
object := object^.Next;
END;
first^.Code[5] := number;
adr := ADR ( first^.Code ) ;
long := 20;
MagicDOS.Fwrite ( FileHandle , long , adr ) ;
IF Subpic THEN
object := first^.Children;
ELSE
object := first^.Next;
END;
WHILE object <> NIL DO
IF (NOT OnlySelected) OR
(OnlySelected AND object^.Selected) THEN
IF ORD(object^.Code[0]) <> ORD(Picture) THEN
long := 20 ;
adr := ADR ( object^.Code ) ;
MagicDOS.Fwrite ( FileHandle , long , adr ) ;
IF object^.Code [ 9 ] > 0 THEN
long := MagicSys.CastToLCard ( object^.Code [ 9 ] ) ;
MagicDOS.Fwrite ( FileHandle , long , object^.CPtr ) ;
END;
CASE VAL(DrawObjectTyp, object^.Code[0]) OF
EpicSolidLine,
EpicDottedLine,
EpicDashedLine :
long2 := 4 * MagicSys.CastToLCard ( object^.Code [ 3 ] ) ;
IF long2 > 0 THEN
MagicDOS.Fwrite ( FileHandle , long2 , object^.EPtr ) ;
END;|
ELSE
long2 := 0;
END;
ELSE
SaveTree(object, TRUE, FALSE);
END;
END;
object := object^.Next ;
END;
(**
RTD.Message('Leaving SaveTree');
**)
END SaveTree;
PROCEDURE LoadTree(flag, SelectIt : BOOLEAN;
anzahl: INTEGER) : BOOLEAN;
(* Ist Flag = 0 so merken wir uns den LastObject-Status und hängen *)
(* den Zweig des Baumes um, dabei gehen wir davon aus, daß das zuletzt *)
(* erzeugte Objekt das Vaterobjekt ist. *)
VAR laststate : ObjectPtrTyp;
i, read : INTEGER;
ok : BOOLEAN;
BEGIN
(**
RTD.Message('LoadTree');
RTD.ShowVar('anzahl', anzahl);
**)
IF flag THEN
laststate := Variablen.LastObject;
END;
read := 0;
ok := TRUE;
WHILE (read<anzahl) DO
long := 20 ;
adr := ADR ( code ) ;
(**
MagicDOS.Fread ( FileHandle , long , adr ) ;
**)
FileIO.ReadNWords( FileHandle, 10, code );
IF ORD(code[0])<>ORD(Picture) THEN
(**
long := MagicSys.CastToLCard ( code [ 9 ] ) ;
**)
IF code[9] > 0 THEN
(**
MagicDOS.Fread ( FileHandle , long , ADR(cbuffer) ) ;
**)
(**
RTD.Message('Text');
RTD.ShowVar('len', code[9]);
**)
FileIO.ReadNBytes( FileHandle, code[9], cbuffer);
cbuffer[code[9]] := 0C;
(**
RTD.Write('T ready', cbuffer);
FOR i:=0 TO code[9] DO
RTD.ShowVar('cbuf', cbuffer[i]);
END;
**)
END (* if *);
CASE VAL(DrawObjectTyp, code[0]) OF
EpicSolidLine,
EpicDottedLine,
EpicDashedLine :
long2 := 4 * MagicSys.CastToLCard ( code [ 3 ] ) ; (* 2 * 2 Bytes *)
IF code[3] > 0 THEN
(**
MagicDOS.Fread ( FileHandle , long2 , ADR(Variablen.ebuffer) ) ;
**)
(**
RTD.Message('Epic-Line');
**)
FileIO.ReadNWords ( FileHandle, 2 * code[3], Variablen.ebuffer );
(**
RTD.Message('EL ready');
**)
END;|
ELSE
long2 := 0;
END (* case *);
(**
RTD.Message('NewOb');
**)
IF long2<>0 THEN
IF long<> 0 THEN
Variablen.NewObject ( code , ADR(cbuffer), ADR(Vari